package Hashtable;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
public class intersection {
    public int[] intersection(int[] nums1, int[] nums2) {
        Set<Integer> hashSet1 = new HashSet<>();
        Set<Integer> hashSet2 = new HashSet<>();
        for (int i : nums1) {
            hashSet1.add(i);
        }
        for (int j : nums2){
            hashSet2.add(j);
        }
        hashSet1.retainAll(hashSet2);
        return hashSet1.stream().mapToInt(Integer::intValue).toArray();
    }
}
